﻿using System;

namespace TextEditor
{


    public class A_ShowAll : A_Action
    {
        public override string ActionName()
        {
            return "showall";
        }

        public override int CheckState()
        {
            return (base.myOwnerDocument.Info.ShowAll ? 1 : 0);
        }

        public override bool isEnable()
        {
            return base.OwnerDocument.EnableShowAll;
        }

        public override bool Execute()
        {
            //**********只要执行显示所有，就把痕迹显示出来包括痕迹的标记(中划线 下划线)
            base.myOwnerDocument.Info.ShowMark = true;

            ZYTextElement lastNotDeletedElement = base.myOwnerDocument.GetLastNotDeletedElement(-1);
            base.myOwnerDocument.Info.ShowAll = !base.myOwnerDocument.Info.ShowAll;
            base.myOwnerDocument.RefreshSize();
            base.myOwnerDocument.ContentChanged();
            if (base.myOwnerDocument.Elements.Contains(lastNotDeletedElement))
            {
                base.myOwnerDocument.Content.SetSelection(base.myOwnerDocument.Elements.IndexOf(lastNotDeletedElement), 0);
            }
            else
            {
                base.myOwnerDocument.Content.SetSelection(0, 0);
            }
            base.myOwnerDocument.UpdateView();
            return true;
        }
    }
}

